GBML manual / Maths

min

The smaller of a and b.

Syntax

min(a, b) -> real

Arguments

NameType
areal
breal

Returns

real

Description

The smaller of a and b.

Given two whole numbers, min hands back a whole number; if either one is a decimal, the answer is a decimal. min_int does the same for whole numbers but refuses a decimal outright.

Example

hsp = min(hsp + 1, 3);

Accelerates this object rightward by 1 every frame, but never past a top speed of 3 - once hsp + 1 would go higher than 3, min keeps handing back 3 instead. See max for capping the other direction, and clamp for both at once against two fixed bounds.

Cost

One comparison - as cheap as this group gets, safe to call every frame.

On the GBA

A direct call to the GBA module’s own min - one comparison. When both numbers are whole numbers the answer is a whole number too; if either is a decimal the answer is a decimal. min_int is the same call, for when you want a decimal refused outright.

See also: maxclampmin_int